<?php
include('class/class_connect.php');
include('class/class_page.php');
include('class/class_news.php');
include('class/abstract/class_paginator.php');
include('class/city_rus.php');
include('class/class_checkGetData.php');


$aCheck=new checkGetData('f');
$aCheck->checkCity($_GET['city']);

session_start();


class aFirmPage extends page
{
	var $cityRus;
	function __construct()
	{
		$this->cityRus=new city_rus_class();
		parent::__construct();
	}
	function title()
	{
		echo 'Новости '.$this->cityRus->city_rus_im($_GET['city']);
	}
	function maincontent()
	{

		echo ('
		<div class="route">
			<div class="routeEl">
				<a href="index.php?city='.$_GET['city'].'">'.$this->cityRus->city_rus_im($_GET['city']).'</a>
			</div>
			<div class="routeEl">
				Новости
			</div>
		</div>
		');
		echo '<center><h1>НОВОСТИ</h1></center>';
        $aPaginator=new newsPaginator();
	}
}

class newsPaginator extends paginator
{
	var $res=array();
	var $newsNum;
	function __construct()
	{
		$aConnect=new connect('fn');
		$this->res=$aConnect->select_all($_GET['city'], "ORDER BY data DESC");
		$this->newsNum=mysql_num_rows($this->res);
		$aConnect=new connect('mn');
		$this->res=$aConnect->select_all($_GET['city'], "ORDER BY data DESC");
		$this->newsNum=$this->newsNum+mysql_num_rows($this->res);
		//$this->row=mysql_fetch_array($res);
		parent::__construct(20);
	}
	function pageContent()
	{
		$aConnect=new connect('fn');
		$news=new news('firms', $_GET['city'], $_GET['id']);
		$res=$aConnect->select_all($_GET['city'], "ORDER BY data DESC LIMIT ".$this->lim.", 10");
		while($row=mysql_fetch_array($res))
		{			echo ('<center><a href="firms.php?city='.$_GET['city'].'&id='.$row['firms_id'].'"><firmsShort>'.$row['firms_short'].'</firmsShort>&nbsp;
			 <firmsName> '.$row['firms_name'].'<firmsName></a></center><br />');
			$news->showANews($row['id'], $row['name'], $row['stext'], $row['data'], $link, 1000);
		}
		$aConnect=new connect('mn');
		$news=new news('malls', $_GET['city'], $_GET['id']);
		$res=$aConnect->select_all($_GET['city'], "ORDER BY data DESC LIMIT ".$this->lim.", 10");
		while($row=mysql_fetch_array($res))
		{			echo ('<center><a href="malls.php?city='.$_GET['city'].'&id='.$row['malls_id'].'"><firmsShort>'.$row['malls_short'].'</firmsShort>&nbsp;
			 <firmsName> '.$row['malls_name'].'<firmsName></a></center><br />');
			$news->showANews($row['id'], $row['name'], $row['stext'], $row['data'], $link, 1000);
		}
	}
	function countRows()
	{
		return($this->newsNum);
	}
}
$aPage=new aFirmPage();

?>